var http_request=false;
var _get, saveget = 1, callback = "";

function _request(url, data) {
 http_request=false;

 if(window.XMLHttpRequest) { // Firefox, Mozilla, Safari, Konqueror
  http_request=new XMLHttpRequest();
  /*
  if(http_request.overrideMimeType) {
   http_request.overrideMimeType('text/xml');
  }
  */
 } else if(window.ActiveXObject) { // ActiveX (IE)
  try {
   http_request=new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    http_request=new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e) {}
  }
 }

 if(!http_request) {
  return{success:0,msg:'Kann keine XMLHTTP-Instanz erzeugen. Siehe Hilfe f&uuml;r weitere Informationen'};
 }
 http_request.onreadystatechange=requestreturn;
 
 if(data==0) {
  http_request.open('GET', url, true);
  http_request.send(null);
 } else {
  http_request.open('POST', url);
  http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  http_request.send(data);
 }
}

function phpget(url, param, field) {
 _get = field;
 saveget = 1;
 _request(url, param);
}

function request(url, param) {
 saveget = 0;
 _request(url, param);
}

function set_callback(func) {
  callback = func;
}

function requestreturn() {

 if(http_request.readyState==4) {
  if(http_request.status==200) {
   if(saveget) {
    document.getElementById(_get).innerHTML = http_request.responseText;
    document.getElementById(_get).value = http_request.responseText;
   }
   if(typeof window[callback] == 'function') window[callback]();
   callback = "";
  }
  else {
   alert('Bei dem Request ist ein Problem aufgetreten.');
  }
 }
}

